package com.example.qxfw.dzzh.service.impl;

import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.example.qxfw.common.entity.yj.AridWarnAnalysisFile;
import com.example.qxfw.dzzh.mapper.AridWarnAnalysisFileMapper;
import com.example.qxfw.dzzh.service.AridWarnAnalysisFileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.sql.Timestamp;
import java.util.List;

@Service
public class AridWarnAnalysisFileServiceImpl implements AridWarnAnalysisFileService {

    @Autowired
    private AridWarnAnalysisFileMapper aridWarnAnalysisFileMapper;

    @Override
    public List<AridWarnAnalysisFile> listByParam(String dateChar,String type, String fileName, String city) {
        return aridWarnAnalysisFileMapper.selectList(Wrappers.<AridWarnAnalysisFile>lambdaQuery()
                .eq(StringUtils.isNotBlank(dateChar),AridWarnAnalysisFile::getDatechar, Timestamp.valueOf(dateChar))
                .eq(AridWarnAnalysisFile::getType,type)
                .eq(AridWarnAnalysisFile::getFilename,fileName)
                .eq(AridWarnAnalysisFile::getCity,city));
    }

    @Override
    public List<AridWarnAnalysisFile> listByParam1(String type, String fileName) {
        return aridWarnAnalysisFileMapper.selectList(Wrappers.<AridWarnAnalysisFile>lambdaQuery()
                .eq(AridWarnAnalysisFile::getType,type)
                .eq(AridWarnAnalysisFile::getFilename,fileName));
    }

    @Override
    public AridWarnAnalysisFile save(AridWarnAnalysisFile aridWarnAnalysisFile) {
        int rows = aridWarnAnalysisFileMapper.insert(aridWarnAnalysisFile);
        return rows!=0?aridWarnAnalysisFile:null;
    }
}
